home *** CD-ROM | disk | FTP | other *** search
/ HyperLib 1997 Winter - Disc 1 / HYPERLIB-1997-Winter-CD1.ISO.7z / HYPERLIB-1997-Winter-CD1.ISO / オンラインウェア / PRG / Prograph Reference Manual.sit / Prograph Reference Manual / Prograph Reference 8-End.rsrc / TEXT_139.txt < prev    next >
Text File  |  1995-10-26  |  2KB  |  57 lines

  1. t MultiUser Access to Datafile Manager  *489*
  2.  
  3. Datafiles created with the Prograph Datafile Manager can be accessed by multiple users if opened in Shared mode (see the description for db-open primitive later in this chapter). To make this possible, the datafile must reside on a shared volume within an AppleTalk network.
  4.  
  5. Applications that open a shared datafile must be aware that other applications may be accessing that datafile. From a programmer窶冱 perspective, the following items must be considered when accessing a datafile:
  6.  
  7. 1.    To replace an existing cluster, lock the cluster, call cluster, replace, then unlock the cluster.
  8.  
  9. 2.    Attempting to read a cluster may result in an error indicating that someone else has locked the cluster; you may try again later;
  10.  
  11. 3.    It is not necessary to explicitly flush a shared datafile, since all shared datafiles are flushed automatically after each write.
  12.  
  13. Locking and Unlocking Clusters  *490*
  14.  
  15. In a shared datafile, multiple users can read a cluster simultaneously; however, only a single user may safely overwrite a cluster. For this reason it is necessary to lock a cluster before writing to the datafile, to prevent another user from writing to the same cluster at the same time. After an application has overwritten a cluster, the cluster should be unlocked to allow other users access to the cluster.
  16.  
  17. _______________________________________________________
  18. NOTE:
  19.  
  20. When a user locks a cluster, that cluster cannot be overwritten or even read by another user until it is unlocked.
  21. --------------------------------------------------------
  22.  
  23. To lock a cluster, call the cluster-lock primitive. This primitive must be supplied with the following:
  24.  
  25. r the table id number, and
  26.  
  27. r the cluster id number. 
  28.  
  29. cluster-lock locks a cluster, thus preventing other users from accessing it, and returns an error number indicating whether or not the primitive succeeded.
  30.  
  31. To unlock a cluster, call the cluster-unlock primitive. This primitive must be supplied with the following:
  32.  
  33. r the table id number, and
  34.  
  35. r the cluster id number. 
  36.  
  37. cluster-unlock unlocks a cluster, allowing other users to access it, and returns an error number indicating whether or not the primitive succeeded.
  38.  
  39. The following sample method locks a cluster before replacing it, and then unlocks the cluster:
  40.  
  41. ツ 
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.